let app = getApp()

Page({

    /**
     * 页面的初始数据
     */
    data: {
        order: {},
        details: [],
        orderId: 0
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            spinShow: true,
            orderId: options.orderId,
            queryParam: {
                status: 0
            },
        });

        let orderId = null
        if (options.orderId) {
            orderId = options.orderId
        } else {
            let obj = wx.getLaunchOptionsSync()
            if (obj) {
                orderId = obj.query.orderId
            }
        }
        this.queryData(orderId)
    },
    queryData: function (orderId) {
        let _this = this
        app.formGet('/app/order/detail?orderId=' + orderId, null).then(res => {
            _this.setData({
                spinShow: false
            });
            wx.stopPullDownRefresh()
            if (res.code === 0) {
                _this.setData({
                    order: res.data.order,
                    details: res.data.details,
                });
            } else if (res.code == 999) {
                app.message(res.message, 'error')
            } else if (res.code == -1) {
                app.message(res.message, 'error')
            } else {
                app.message(res.message, 'error')
            }
        }).catch(e => {
            _this.setData({
                spinShow: false
            });
            app.message(e, 'error')
        })
    },
    handleBack() {
        wx.navigateBack()
    }
})